/* 
 * File:   Item.cpp
 * Author: vicror
 * 
 * Created on October 8, 2011, 8:03 PM
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files
 * (the "Software"), to deal in the Software without restriction,
 * including without limitation the rights to use, copy, modify, merge,
 * publish, distribute, sublicense, and/or sell copies of the Software,
 * and to permit persons to whom the Software is furnished to do so,
 * subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

#include "Item.h"
namespace SearchEnginer {

    Item::Item() {
        _index = 0;
        _step = 0;
    }

    Item::Item(int index, int step) {
        _index = index;
        _step = step;
    }

    Item::Item(const Item& orig) {
        _index = orig._index;
        _step = orig._step;
    }

    Item::~Item() {
    }

    int Item::index() const {
        return _index;
    }

    int Item::step() const {
        return _step;
    }

    bool Item::operator==(const Item& orig) const {
        return _index == orig._index && _step == orig._step;
    }

    bool Item::operator==(const int orig) const {
        return _index == orig;

    }

    bool Item::operator!=(const Item& orig) const {
        return _index != orig._index || _step != orig._step;

    }

    bool Item::operator!=(const int orig) const {
        return _index != orig;
    }

    bool Item::operator>(const Item& orig) const {
        if (_index == orig._index) {
            return _step > orig._step;
        } else {
            return _index > orig._index;
        }
    }

    bool Item::operator>(const int orig) const {
        return _index > orig;
    }

    bool Item::operator<(const Item& orig) const {
        if (_index == orig._index) {
            return _step < orig._step;
        } else {
            return _index < orig._index;
        }
    }

    bool Item::operator<(const int orig) const {
        return _index < orig;
    }

    bool Item::operator>=(const Item& orig) const {
        if (_index == orig._index) {
            return _step >= orig._step;
        } else {
            return _index > orig._index;
        }
    }

    bool Item::operator>=(const int orig) const {
        return _index >= orig;
    }

    bool Item::operator<=(const Item& orig) const {
        if (_index == orig._index) {
            return _step <= orig._step;
        } else {
            return _index < orig._index;
        }
    }

    bool Item::operator<=(const int orig) const {
        return _index <= orig;
    }

    Item& Item::operator =(const Item& orig) {
        if (&orig != this) {
            _index = orig._index;
            _step = orig._step;
        }
        return *this;
    }

    bool Item::isEqualWithMix(const Item& orig, int mix) const {
        return _index == orig._index && _step + mix == orig._step;
    }

}